// 增&改
function setCookie(key, val, d) {
  let str = `${key}=${val};`;
  if (d != undefined) {
    let date = new Date();
    date.setDate(date.getDate() + d);
    str += `expires=${date};`;
  }
  document.cookie = str;
}
// 删
removeCookie = function (key) {
  setCookie(key, "", -1);
};
// 查找
getCookie = (key) => {
  let arr = document.cookie.split("; ");
  for (let i = 0; i < arr.length; i++) {
    let sArr = arr[i].split("=");
    if (sArr[0] == key) {
      return sArr[1];
    }
  }
};
